<?php  
class ControllerCommonFooter extends Controller {
	protected function index() {
		
		$this->language->load('common/footer');
		
		M('catalog/page');		
		$this->data['informations'] = array();

		foreach ($this->model_catalog_page->getPages() as $result) {
			if ($result['bottom']) {
				$this->data['informations'][] = array(
					'title' => $result['title'],
					'href'  => U('page/index', 'page_id=' . $result['page_id'] . '&seo_url=' . $result['seo_url']),
				);
			}
    	}
		
		//$this->data['queries'] = sprintf($this->_['text_queries'], $this->db->getQueryCount());
		$this->data['powered'] = sprintf($this->_['text_powered'], C('config_name'), date('Y', time()));	
		
		//live chat module
		$livechat_setting = C('livechat_setting');
		if ($livechat_setting && $livechat_setting['enabled']) {
			$this->data['livechat'] = $this->getChild('module/livechat', null, 'livechat', 3600);
		}
		else {
			$this->data['livechat'] = '';
		}
		
		// Whois Online
		if (C('config_customer_online')) {
			M('tool/online');
			
			if (isset($this->request->server['REMOTE_ADDR'])) {
				$ip = $this->request->server['REMOTE_ADDR'];
			} else {
				$ip = ''; 
			}
			
			if (isset($this->request->server['HTTP_HOST']) && isset($this->request->server['REQUEST_URI'])) {
				$url = 'http://' . $this->request->server['HTTP_HOST'] . $this->request->server['REQUEST_URI'];	
			} else {
				$url = '';
			}
			
			if (isset($this->request->server['HTTP_REFERER'])) {
				$referer = $this->request->server['HTTP_REFERER'];	
			} else {
				$referer = '';
			}
			
			$this->model_tool_online->whosonline($ip, $this->customer->getId(), $url, $referer);
		}
		
		$this->data['google_analytics'] = v5_html_entity_decode(C('config_google_analytics'));
		
		$this->render('common/footer.tpl');
	}
}
?>